package com.hr.controller;

import com.hr.entity.ConfigPublicChar;

import com.hr.entity.R;
import com.hr.service.ConfigPublicCharService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.nio.channels.Pipe;

import com.hr.service.ConfigPublicCharService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.List;

@RestController
@RequestMapping("/configPublicChar")
public class ConfigPublicCharController {
    @Autowired
    private ConfigPublicCharService service;

    /**
     * 查询公共字段表
     * @return
     */
    @RequestMapping("/queryList")
    public List<ConfigPublicChar> queryList(){
        List<ConfigPublicChar> list = service.queryList();
        return list;
    }

    /**
     * 删除
     * @param pbcid
     * @return
     */
    @DeleteMapping("/del")
    public R del(Integer pbcid){
        boolean del = service.del(pbcid);
        return del ? R.ok("删除成功"):R.fail("删除失败");
    }

    /**
     * 保存/修改
     * @param configPublicChar
     * @return
     */
    @PostMapping("/save")
    public R save(
            @RequestBody
            ConfigPublicChar configPublicChar){
        boolean save = service.save(configPublicChar);
        return save ? R.ok("保存成功"):R.fail("保存失败");
    }

//    private ConfigPublicCharService configPublicCharService;
//
//    @GetMapping("/queryList")
//    public List<ConfigPublicChar> queryList(){
//        List<ConfigPublicChar> list = configPublicCharService.queryList();
//        System.out.println("*** list"+list);
//        return list;
//    }

}
